# -*- coding: utf-8 -*-
import ssh_run_cmd as run
import write_data_to_excel as excel

ssh = run.ssh_connect("ip", "root", "passwd", 22)

channel = run.get_cycle_channel(ssh)
res = run.run_cycle_cmd(channel, 'mysql -uroot -pPASSWD')
print(res)
res = run.run_cycle_cmd(channel, 'use renren_fast;')
print(res)
res = run.run_cycle_cmd(channel, 'select * from sys_role_menu limit 0, 100;')
print('=' * 100)
res = res.replace('+', '').replace('|', '').replace('-', '')
print(res)
data_arr = res.split('\n')
data_arr_arr = []
for data in data_arr:
    if data.__contains__('select') or data == '\r' or data.__contains__('mysql') or data.__contains__(' rows in set ('):
        continue
    else:
        data_arr_arr.append(data.split())

excel.write_str_arr("renren.xlsx", data_arr_arr)
print('end')